package com.sishu.njrtsdms.domain.core;

import java.util.Collections;
import java.util.List;

import cn.hutool.core.collection.CollUtil;


public class PageInfo<T> {

    private final List<T> content;

    private final Integer page;

    private final Integer size;

    public PageInfo(List<T> content, Integer page, Integer size) {
        if (CollUtil.isEmpty(content)) {
            this.content = Collections.emptyList();
        } else {
            this.content = content;
        }
        this.page = page;
        this.size = size;
    }


    public List<T> getContent() {
        return content;
    }

    public Integer getSize() {
        return size;
    }

    public Integer getNumberOfElements() {
        return content.size();
    }

    public Integer getCurrentPage() {
        return page > 0 ? page : 1;
    }


    public static <O> PageInfo<O> emptyPageInfo() {
        return new PageInfo<>(Collections.emptyList(), 0, 0);
    }

}
